import torch
import pandas as pd

def predict(model, test_loader, device):
    model.eval()
    predictions = []
    
    with torch.no_grad():
        for batch_texts in test_loader:
            batch_texts = batch_texts.to(device)
            outputs = model(batch_texts)
            preds = torch.argmax(outputs, dim=1).cpu().numpy()
            predictions.extend(preds)
    
    return predictions

def save_predictions(predictions, output_path):
    submit_df = pd.DataFrame({'label': predictions})
    submit_df.to_csv(output_path, index=False)
